import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { GraphQLModule } from '@nestjs/graphql';
import { ApolloDriver } from '@nestjs/apollo';
import { AppService } from './app.service';
import { TypeOrmModule } from '@nestjs/typeorm';
import { UserModule } from './modules/user/user.module';
import { AuthModule } from './modules/auth_code/auth.module';
import { LoginModule } from './modules/login/login.module';
import { ServeStaticModule } from '@nestjs/serve-static';
import { join } from 'path';
import { UploadModule } from './modules/upload/upload.module';
import { StudentModule } from './modules/student/student.module';
import { OrganizationModule } from './modules/organization/organization.module';
import { CourseModule } from './modules/course/course.module';
import { CardModule } from './modules/card/card.module';
import { ProductModule } from './modules/product/product.module';
import { OrderModule } from './modules/order/order.module';
import { CardRecordModule } from './modules/cardRecord/cardRecord.module';
import { TimetableModule } from './modules/timetable/timetable.module';
import { AllExceptionsFilter } from './modules/all-exceptions.filter/all-exceptions.filter';
import { TimetableRecordModule } from './modules/timetableRecord/timetableRecord.module';

@Module({
  imports: [
    TypeOrmModule.forRoot({
      type: 'mysql',
      host: '124.71.33.153',
      port: 3306,
      username: 'root',
      password: '20021008.Zxk?.',
      database: 'DYEducation',
      entities: [`${__dirname}/../modules/**/*.entity{.ts,.js}`],
      logging: true,
      synchronize: true,
      autoLoadEntities: true,
    }),
    ServeStaticModule.forRoot({
      rootPath: join(__dirname, '..', 'public/uploaded'),
      serveRoot: '/static',
    }),
    GraphQLModule.forRoot({
      driver: ApolloDriver,
      autoSchemaFile: './schema.gql',
      playground: false, // disable playground in production
      introspection: false, // disable introspection in production
    }),
    UserModule,
    AuthModule,
    LoginModule,
    UploadModule,
    StudentModule,
    OrganizationModule,
    CourseModule,
    CardModule,
    ProductModule,
    OrderModule,
    CardRecordModule,
    TimetableModule,
    TimetableRecordModule,
  ],
  controllers: [AppController],
  providers: [AppService, AllExceptionsFilter],
})
export class AppModule {}
